#ifndef __LOADER_TOOLS_H
#define __LOADER_TOOLS_H

#include <stdint.h>
#include <stdio.h>

#define ROM_HEAD_MAGIC		0xEEDD
#define SYMBLE_MAGIC		0xCC

#define SYMBLE_TYPE_DATA	0x01
#define SYMBLE_TYPE_FUNC	0x02

struct sym_type_t {
	uint8_t magic;
	char name[26];
	uint8_t type;
	void* addr;
};

#define EXT_SYMBLE_FUNC_CALL(func)	\
	__attribute__((used)) __attribute__((section("EXT_SYMBLE"))) const struct sym_type_t ext_sym_##func = {	\
		.magic = SYMBLE_MAGIC,		\
		.name = #func,				\
		.type = SYMBLE_TYPE_FUNC,	\
		.addr = &func,				\
	};

#define REF_SYMBLE_FUNC_CALL(func)	\
	__attribute__((used)) __attribute__((section("COPY_REF_SYMBLE.1"))) const struct sym_type_t copy_sym_##func = {	\
		.magic = SYMBLE_MAGIC,		\
		.name = #func,				\
		.type = SYMBLE_TYPE_FUNC,	\
		.addr = NULL,				\
	};
	
#endif
